function [output]=detect_face(Irgb,SkinIndexRow,SkinIndexCol)
Irgb=double(Irgb);
height=size(Irgb,1);
width=size(Irgb,2);

%Creating the mask
S=zeros(height, width);
for i=1:length(SkinIndexRow)
    S(SkinIndexRow(i),SkinIndexCol(i))=1;
end

%Compensating the image
SN=zeros(height,width);
for i=1:height-5
    for j=1:width-5
        localSum=sum(sum(S(i:i+4, j:j+4)));
        SN(i:i+5, j:j+5)=(localSum>12);
    end
end

r=Irgb(:,:,1);
g=Irgb(:,:,2);
b=Irgb(:,:,3);
r=double(r);
g=double(g);
b=double(b);
r=S.*r;
g=S.*g;
b=S.*b;
r=uint8(r);
g=uint8(g);
b=uint8(b);

output(:,:,1)=r;
output(:,:,2)=g;
output(:,:,3)=b;

figure,imshow(output);
title('skin');